package strings;

/**
 * @author pengfei.hpf
 * @date 2020/3/22
 * @verdion 1.0.0
 */
public class ConvertToBase7 {
    public String convertToBase7(int num) {
        boolean isMin = num < 0;
        StringBuilder builder = new StringBuilder();
        if(num > 0){
            num = - num;
        }
        while(num < 0){
            int t = num%7;
            t = -t;
            builder.insert(0, t);
            num = num /7;

        }
        if(isMin){
            builder.insert(0, "-");
        }
        return builder.toString();

    }
}
